<template>
	<view class="content">
		<view class="info lend">
			<view class="item2" v-for="(item,i) in list1">
				<image :src="require(`@/static/img/${item.img}`)" mode="widthFix"></image>
				<!-- <img :src="require(`@/static/img/${item.img}`)" alt="" /> -->
				<view class="text">{{item.title}}</view>
				<view v-if="!item.num && item.text" class="color_9">{{item.text}}</view>
				<view v-else class="btn" @click="edit(item)">
					<text>修改</text>
					<image src="@/static/img/safety_img.png" mode="widthFix"></image>
				</view>
			</view>
		</view>
		<view class="login_btn" @click="out">退出登录</view>
	</view>
</template>

<script>
	import {
		userInfo,
		logout
	} from '@/common/js/index.js'
	export default {
		data() {
			return {
				list1: [{
						img: "safety_1.png",
						title: "昵称",
						text: ""
					},
					{
						img: "safety_2.png",
						title: "实名认证",
						text: "",
						num: 99
					},
					{
						img: "safety_3.png",
						title: "登录密码",
						text: "",
						num: 1
					},
					{
						img: "safety_4.png",
						title: "绑定邮箱",
						text: "",
						num: 2
					},
					{
						img: "safety_5.png",
						title: "绑定手机",
						text: "",
						num: 3
					},
					{
						img: "safety_6.png",
						title: "二级密码",
						text: "",
						num: 4
					},
				]
			}
		},
		onLoad() {

		},
		onShow() {
			this.user()
		},
		methods: {
			out() {
				logout().then(res => {
					console.log(res);
					uni.showToast({
						title: res.msg
					})
					uni.setStorageSync('token', '')
					setTimeout(function() {
						uni.reLaunch({
							url: '/pages/inlet/login'
						})
					}, 2000)
				})
			},
			user() {
				userInfo().then(res => {
					console.log(res);
					this.list1[0].text = res.data.short_name
					this.list1[1].text = res.data.real_name
					this.list1[2].text = res.data.mobile
					this.list1[3].email = res.data.email
					this.list1[5].text = res.data.mobile
				})
			},
			edit(e) {
				if (e.num == 99) {
					uni.navigateTo({
						url: "/pages/authentication/autonym"
					})
				} else {
					uni.navigateTo({
						url: "/pages/me/edit?num=" + e.num + '&email=' + e.email+ '&phone=' + e.text
					})
				}
			}
		},
	}
</script>

<style scoped lang="scss">
	.content {
		/* background: white; */
		position: relative;
		overflow: hidden;
	}

	.info {
		margin: 40rpx 30rpx;
		padding: 0 30rpx 140rpx;
		background-color: white;
		background: #FFFFFF;
		border-radius: 12rpx;
		overflow: hidden;

		.item2 {
			height: 118rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			border-bottom: 2rpx solid #EEEEEE;

			image {
				width: 48rpx;
			}

			.text {
				flex: 1;
				margin-left: 16rpx;
			}

			.btn {
				display: flex;
				align-items: center;
				color: #1E89FF;

				image {
					margin-left: 16rpx;
				}
			}

			.color_9 {
				color: #999999;
			}
		}
	}

	.login_btn {
		width: 460rpx;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		border-radius: 40rpx 40rpx 40rpx 40rpx;
		border: 2rpx solid #FDB1B1;
		font-weight: 500;
		font-size: 32rpx;
		color: #FF453A;
		margin: 150rpx auto 0;
	}
</style>